package ru.beta2.testyard.config;

import ru.beta2.testyard.config.defaults.DefaultPlayersHandler;
import ru.beta2.testyard.config.defaults.DefaultSerializationHandler;
import ru.beta2.testyard.config.defaults.DefaultTaggedHandler;

/**
 * Class for configure testyard.
 * <br/>
 * User: Inc
 * Date: 18.01.2009
 * Time: 14:26:19
 */
public class Configuration
{

    private String sgsHost = "localhost";
    private int sgsPort = 1139;

    private int shutdownTimeout = 5000;
    private int messagesTimeout = 2000;

    private String jmxServiceURL;
    private String testyardHookMBeanName;

    private PlayersHandler playersHandler = new DefaultPlayersHandler();
    private SerializationHandler serializationHandler = new DefaultSerializationHandler();
    private TaggedHandler taggedHandler = new DefaultTaggedHandler();

    /**
     * Server application host, default "localhost"
     * @return
     */
    public String getSgsHost()
    {
        return sgsHost;
    }

    public void setSgsHost(String sgsHost)
    {
        this.sgsHost = sgsHost;
    }

    /**
     * Server application port, default 1139
     * @return
     */
    public int getSgsPort()
    {
        return sgsPort;
    }

    public void setSgsPort(int sgsPort)
    {
        this.sgsPort = sgsPort;
    }

    /**
     * Server application MBean Server URL, default is null.
     * Something like "service:jmx:rmi://localhost/jndi/rmi://localhost:1099/sgs-server";
     * @return
     */
    public String getJMXServiceURL()
    {
        return jmxServiceURL;
    }

    public void setJMXServiceURL(String jmxServiceURL)
    {
        this.jmxServiceURL = jmxServiceURL;
    }

    /**
     * Testyard MBean object name, default is null.
     * @return
     */
    public String getTestyardHookMBeanName()
    {
        return testyardHookMBeanName;
    }

    public void setTestyardHookMBeanName(String testyardHookMBeanName)
    {
        this.testyardHookMBeanName = testyardHookMBeanName;
    }

    /**
     * Players handler, default implementation {@link ru.beta2.testyard.config.defaults.DefaultPlayersHandler}
     * @return
     */
    public PlayersHandler getPlayersHandler()
    {
        return playersHandler;
    }

    public void setPlayersHandler(PlayersHandler playersHandler)
    {
        this.playersHandler = playersHandler;
    }

    /**
     * Serialization handler, default implementation {@link ru.beta2.testyard.config.defaults.DefaultSerializationHandler}
     * @return
     */
    public SerializationHandler getSerializationHandler()
    {
        return serializationHandler;
    }

    public void setSerializationHandler(SerializationHandler serializationHandler)
    {
        this.serializationHandler = serializationHandler;
    }

    /**
     * Tagged handler, default implementation {@link ru.beta2.testyard.config.defaults.DefaultTaggedHandler}
     * @return
     */
    public TaggedHandler getTaggedHandler()
    {
        return taggedHandler;
    }

    public void setTaggedHandler(TaggedHandler taggedHandler)
    {
        this.taggedHandler = taggedHandler;
    }

    /**
     * Timeout for shutdown testyard, default 5000 ms. Shutdown includes sending logout requests for all logged in
     * players and waiting for disconnection each of them.  
     * @return shutdown timeout in ms
     */
    public int getShutdownTimeout()
    {
        return shutdownTimeout;
    }

    public void setShutdownTimeout(int shutdownTimeout)
    {
        this.shutdownTimeout = shutdownTimeout;
    }

    /**
     * Messages receive timeout after which test failed (if no messages received), default 2000 ms 
     * @return messages receive timeout in ms
     */
    public int getMessagesTimeout()
    {
        return messagesTimeout;
    }

    public void setMessagesTimeout(int messagesTimeout)
    {
        this.messagesTimeout = messagesTimeout;
    }
}
